﻿using System;
using System.ComponentModel.DataAnnotations;

namespace Test.Entities
{
	public abstract class Identifiable : Entity, IIdentifiable
	{
		#region Fields

		private Guid _id;

		#endregion

		#region Properties

		/// <summary>
		/// The unique id of the entity.
		/// </summary>
		[Required]
		public virtual Guid Id
		{
			get
			{
				if (_id == Guid.Empty)
				{
					_id = Guid.NewGuid();
				}

				return _id;
			}
			set
			{
				_id = value;
			}
		}

		#endregion
	}
}